//创建右侧客服栏
function SideQQ() {
	$("#side-qq").load("directives/qq_kefu/side-qq.html");
	var winWidth = document.body.clientWidth;
	if(winWidth <= 1000) {
		$("#side-qq").hide();
		$("#side-tg").hide();
	}
}

//设置cookie
function setCookie(name, value, iday) {
    var oDate = new Date();
    oDate.setDate(oDate.getDate() + iday);
    document.cookie = name + '=' + value + ';expires=' + oDate;
}
//获取cookie
function getCookie(name) {
    var arr = document.cookie.split(";");
    for (var i = 0; i < arr.length; i++) {
        var arr2 = arr[i].split("=");
        if (arr2[0] == name) {
            return arr2[1];
        }
    }
}
//删除cookie
function reMoveCookie(name) {
    setCookie(name, 1, -1);
}
//获取cookie
$(function() {
    if(getCookie('openState') == 'true') {
       $(".QQ_S").css("display", "block");
	   $(".QQ_S1").css("display", "none");
    }
	else if(getCookie('openState') == 'false'){
		$('.QQ_S').css("display","none");
		$('.QQ_S1').css("display","block");
	}
});
//显示隐藏方法
function HideFoot(){
	setCookie("openState","false",7);
	var winHeight = $(window).height();
	var objHeight = $(".QQ_S").height();
	var objTop = winHeight - objHeight - 15;
	$(".QQ_S").animate({top:objTop},100,function(){
		$('.QQ_S').css("display","none");
		$('.QQ_S1').css("display","block");		
	});
}
function ShowFoot(){
	setCookie("openState","true",7);
	$(".QQ_S").css("display", "block");
	$(".QQ_S1").css("display", "none");
	$(".QQ_S").animate({top:"40%"},100);
}
//返回顶部
function backToTop(){
	$("html,body").animate({ scrollTop: 0 },100,function(){
	});
}


/**
 * 点击QQ交谈
 */
function QQTalk() {
	var date = new Date();
	var Hour = date.getHours();	//时间：时
	
	if(Hour >= 8 && Hour < 12 || Hour >= 13 && Hour < 17 || Hour >= 19 && Hour < 22) {
		location.replace("tencent://message/?uin=294944166&Site=qq&Menu=yes");
	} else if(Hour >= 22 && Hour <= 23) {
		location.replace("tencent://message/?uin=1121248482&Site=qq&Menu=yes");
	} else {
		var num = Math.random();	//[0,1)的随机数
		if(num < 0.5) {
			location.replace("tencent://message/?uin=294944166&Site=qq&Menu=yes");
		} else {
			location.replace("tencent://message/?uin=1121248482&Site=qq&Menu=yes");
		}
	}
}
